/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.apt.Bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;
import org.apt.connectDB.MyConnect;

/**
 *
 * @author MinhThang
 */
public class create_lecture_event_bean extends org.apache.struts.action.ActionForm {
            private String txtEventName;
            private FormFile fileImage;
            private String txtStart;
            private String txtEnd;
            private String txtEventDay;
            private String txtLocation;
            private String editorDefault;
            private String txtPrize;
            private String txtPrice;
            private String txtMaxJoin;
           private  String txtCurrent;
           private String ddlStatus;
   

    /**
     *
     */
    public create_lecture_event_bean() {
        super();
        // TODO Auto-generated constructor stub
    }
    public boolean CreateLectureEvent(){
        //Insert data to LectureEvent table
        Connection conn=null;
        PreparedStatement ps=null;
        FormFile file=null;
        file=getFileImage();
        String sql="INSERT INTO [dbo].[LectureEvent] ([EventName], [Image], [Start], [End], [EventDay], [Location], [Content], [Prize], [PriceJoin], [CurrentJoin], [MaxJoin], [Status], [Description]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)";
        try {
            conn=MyConnect.getConnection();
            ps=conn.prepareCall(sql);
            ps.setString(1, getTxtEventName());
            ps.setString(2, file.getFileName());
            ps.setString(3, getTxtStart());
            ps.setString(4, getTxtEnd());
            ps.setString(5, getTxtEventDay());
            ps.setString(6, getTxtLocation());
            ps.setString(7, getEditorDefault());
            ps.setString(8, getTxtPrize());
            ps.setFloat(9, Float.parseFloat(getTxtPrice()));
            ps.setInt(10, Integer.parseInt(getTxtCurrent()));
            ps.setInt(11, Integer.parseInt(getTxtMaxJoin()));
            String status=getDdlStatus();
            boolean tus=true;
            if(status=="Unable"){
                tus=false;
            }
            ps.setBoolean(12, tus);
            ps.setString(13, "");
            ps.executeUpdate();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    /**
     * @return the txtEventName
     */
    public String getTxtEventName() {
        return txtEventName;
    }

    /**
     * @param txtEventName the txtEventName to set
     */
    public void setTxtEventName(String txtEventName) {
        this.txtEventName = txtEventName;
    }

    /**
     * @return the fileImage
     */
    public FormFile getFileImage() {
        return fileImage;
    }

    /**
     * @param fileImage the fileImage to set
     */
    public void setFileImage(FormFile fileImage) {
        this.fileImage = fileImage;
    }

    /**
     * @return the txtStart
     */
    public String getTxtStart() {
        return txtStart;
    }

    /**
     * @param txtStart the txtStart to set
     */
    public void setTxtStart(String txtStart) {
        this.txtStart = txtStart;
    }

    /**
     * @return the txtEnd
     */
    public String getTxtEnd() {
        return txtEnd;
    }

    /**
     * @param txtEnd the txtEnd to set
     */
    public void setTxtEnd(String txtEnd) {
        this.txtEnd = txtEnd;
    }

    /**
     * @return the txtEventDay
     */
    public String getTxtEventDay() {
        return txtEventDay;
    }

    /**
     * @param txtEventDay the txtEventDay to set
     */
    public void setTxtEventDay(String txtEventDay) {
        this.txtEventDay = txtEventDay;
    }

    /**
     * @return the txtLocation
     */
    public String getTxtLocation() {
        return txtLocation;
    }

    /**
     * @param txtLocation the txtLocation to set
     */
    public void setTxtLocation(String txtLocation) {
        this.txtLocation = txtLocation;
    }

    /**
     * @return the editorDefault
     */
    public String getEditorDefault() {
        return editorDefault;
    }

    /**
     * @param editorDefault the editorDefault to set
     */
    public void setEditorDefault(String editorDefault) {
        this.editorDefault = editorDefault;
    }

    /**
     * @return the txtPrize
     */
    public String getTxtPrize() {
        return txtPrize;
    }

    /**
     * @param txtPrize the txtPrize to set
     */
    public void setTxtPrize(String txtPrize) {
        this.txtPrize = txtPrize;
    }

    /**
     * @return the txtPrice
     */
    public String getTxtPrice() {
        return txtPrice;
    }

    /**
     * @param txtPrice the txtPrice to set
     */
    public void setTxtPrice(String txtPrice) {
        this.txtPrice = txtPrice;
    }

    /**
     * @return the txtMaxJoin
     */
    public String getTxtMaxJoin() {
        return txtMaxJoin;
    }

    /**
     * @param txtMaxJoin the txtMaxJoin to set
     */
    public void setTxtMaxJoin(String txtMaxJoin) {
        this.txtMaxJoin = txtMaxJoin;
    }

    /**
     * @return the txtCurrent
     */
    public String getTxtCurrent() {
        return txtCurrent;
    }

    /**
     * @param txtCurrent the txtCurrent to set
     */
    public void setTxtCurrent(String txtCurrent) {
        this.txtCurrent = txtCurrent;
    }

    /**
     * @return the ddlStatus
     */
    public String getDdlStatus() {
        return ddlStatus;
    }

    /**
     * @param ddlStatus the ddlStatus to set
     */
    public void setDdlStatus(String ddlStatus) {
        this.ddlStatus = ddlStatus;
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    
}
